package org.kk.a.sort;
import static org.kk.util.Tool.*;
public class QuickSort {
    public static void main(String[] args) {
        int[] arr = {7,6,4,2,3,1,5,8,9,10};
        sort(arr);
        print(arr);
        System.out.println("Hello World");
    }
    private static void sort(int[] arr){
        sort(arr, 0, arr.length -1);
    }
    private static void sort(int[] arr, int left, int right){
        if(left >= right) return;
        int key = arr[left];
        int i = left, j = right;
        while(i != j){
            while(arr[j] >= key && i < j) j--;
            while(arr[i] <= key && i < j) i++;
            if(i < j) swap(arr, i , j);
        }
        arr[left] = arr[i];
        arr[i] = key;
        sort(arr, left, i -1);
        sort(arr, i + 1, right);
    }
}
